#include <bits/stdc++.h>
using namespace std;
vector<int>s;
int m,n;
int main(){
	cin>>m>>n;
	for(int i=1;i<=m;++i){
		int x;cin>>x;
		s.push_back(x);
	}
	for(int i=1;i<=n;++i){
		int x,y;cin>>x>>y;
        reverse(s.begin()+x-1,s.begin()+y);
	}
	for(unsigned i=0;i<s.size();++i)
		cout<<s.at(i)<<' ';
	cout<<endl;
	return 0;
}
